<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$w=$_REQUEST['winW']*90/100;
$mm=$w."px";
$c1=$w*10/100;
$c2=$w*20/100;
$c4=200;
$c3=$w-($c1+$c2+$c4);
include '../sort/sorclass.php';
$connection1 = mysql_connect("1.234.20.151", "cam", "5678" ) ;
mysql_select_db("elicam", $connection1);
mysql_query("set names 'utf8'");
$sql="select t.id,c.name,t.car_datetime,t.carnumber,c.host,t.filename,t.isReg 
from carnum t ,configcamera c 
where t.id=c.id and t.car_datetime>='2011-01-01 00:00:00' 
and t.car_datetime<='2013-01-23 23:59:59' 
and t.id in ( 1013 ) order by t.car_datetime desc  ";

$m=mysql_query($sql,$connection1);
$_SESSION['mrs']=array();
/*$_SESSION['temname']=array();
$_SESSION['temcarnum']=array();*/
$_SESSION['mname']=array();
$_SESSION['mcarnum']=array();
$sl=mysql_num_rows($m);
if($sl>0){
	$ngu=0;
	while($r=mysql_fetch_array($m)){
		$ob= new sort();
		$ob->newsort($r['id'], $r['name'], $r['car_datetime'], $r['carnumber'], $r['filename'], $r['host'], $r['isReg']);
		$_SESSION['mrs'][$ngu++]=$ob;
		/*$_SESSION['temname'][$ob->name]="gtten";
		$_SESSION['temcarnum'][$ob->carnum]="gtcarnum";*/
	}
}
$_SESSION['msort']=array();
$_SESSION['msort']['carnumber']=1;
$_SESSION['msort']['datetime']=1;
$_SESSION['msort']['name']=1;
$_SESSION['msort']['id']=1;
mysql_close($connection1);
?>

	<table cellspacing="0" cellpadding="0" border="0" width="<?php echo $mm;?>" >
	  <tr>
	    <td>
	       <table cellspacing="0" cellpadding="0" border="1" width="<?php echo $mm;?>" >
	         <tr>
	            <th width="<?php echo $c1."px";?>">id</th>
	            <th width="<?php echo $c2."px";?>"><a style="cursor:pointer;color:blue;" onclick="sordiem('name')">name</a></th>
	            <th width="<?php echo $c3."px";?>"><a style="cursor:pointer;color:blue;" onclick="sordiem('carnumber')">carnum</a></th>
	            <th width="<?php echo $c4."px";?>"><a style="cursor:pointer;color:blue;" onclick="sordiem('datetime')">datetime</a></th>
	         </tr>
	       </table>
	    </td>
	  </tr>
	  <tr>
	    <td>
	       <div id="show" style="width:$mm; height:400px; overflow-y:auto; overflow-x:hidden;  clip-rect:(0px,$mm, 400px, 0px);" >
	       <?php 
	       if($sl>0){
	       ?>
	         <table cellspacing="0" cellpadding="0" border="1" width="<?php echo $mm;?>" >
	         	<tr><td colspan="4"><?=$sl?></td></tr>
	         <?php 
	         for($i=0;$i<$sl;$i++){
	         	$obj=unserialize (serialize ($_SESSION['mrs'][$i]));
	         ?>
	           <tr>
	             <td width="<?php echo $c1."px";?>"><?=$obj->id?></td>
	             <td width="<?php echo $c2."px";?>"><?=$obj->name?></td>
	             <td width="<?php echo $c3."px";?>"><?=$obj->carnum?></td>
	             <td width="<?php echo $c4."px";?>"><?=$obj->datetime?></td>
	           </tr>
	          <?php }?>
	         </table>  
	       <?php 
	       }
	       ?>
	       </div>
	    </td>
	  </tr>
	</table>